#!/usr/bin/python
# vim:fileencoding=utf8

"""
Тестирующий модуль.
"""

import random
import unittest
import language
from gnTai.aiexception import AIException
import os


class TestKnowledge(unittest.TestCase):
    def setUp(self):
        path = os.path.realpath(os.path.join(
                            os.path.dirname(__file__),
                            '..', '..', '..', 'data', 'words.xml',
                            ))
        self.knowledge = language.EnglishKnowledge(path)
    
    def test_dict(self):
        self.assert_(self.knowledge.is_part_of_speech('the', 'article'))
        self.assert_(self.knowledge.is_part_of_speech('love', 'noun'))
        self.assert_(self.knowledge.is_part_of_speech('love', 'verb'))
        self.assert_(self.knowledge.is_part_of_speech('human', 'noun'))
        love = self.knowledge.get_part_of_speech('love', 'noun')
        self.assertEqual(love.to_string(plurum=True, common=False), "loves'")
        exist = self.knowledge.get_part_of_speech('exist', 'verb')
        self.assertEqual(exist.to_string(plurum=False, person=3), "exists")
        
        
def suite():
    suite = unittest.TestSuite()
    suite.addTest(TestKnowledge('test_dict'))
    return suite


if __name__ == '__main__':
    print os.path.dirname(__file__)
    print os.path.realpath(os.path.join(
                            os.path.dirname(__file__),
                            '..\..\..\data\words.xml',
                            ))
    unittest.main()
